package org.alex.samples.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "exam_user_role")
public class ExamUserRole implements Serializable {

	private static final long serialVersionUID = -7620667137696920198L;
	
	@Id
	@Column(name="role_id",nullable = false)
	private int roleId;
	
	@Id
	@Column(name="user_id",nullable = false)
	private String userId;
	
	@ManyToOne(cascade = {CascadeType.DETACH,CascadeType.PERSIST,CascadeType.MERGE},optional = false,fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id")
	private User examUser;
	
	@ManyToOne(cascade = {CascadeType.DETACH,CascadeType.PERSIST,CascadeType.MERGE})
	@JoinColumn(name = "role_id")
	private ExamRole examRole;
	
	public ExamUserRole( int roleId,String userId,User examUser,ExamRole examRole){
		super();
		this.roleId=roleId;
		this.userId=userId;
		this.examUser=examUser;
		this.examRole=examRole;
	}
	public ExamUserRole(){
		super();
	}

	public User getExamUser() {
		return examUser;
	}

	public void setExamUser(User examUser) {
		this.examUser = examUser;
	}

	public ExamRole getExamRole() {
		return examRole;
	}

	public void setExamRole(ExamRole examRole) {
		this.examRole = examRole;
	}

	public int getRoleId() {
		return roleId;
	}

	public void setRoleId(int roleId) {
		this.roleId = roleId;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

}
